//
//  MyCountNetwork.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/16.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "MyCountNetwork.h"
#import "GFXNetworkHandle.h"
#import "ChargeListModel.h"
#import "MyFutureModel.h"

NSString * const MyCount = @"auth/user/my/account";//账户
NSString * const IncomeList = @"auth/user/income/list";//收益详情
NSString * const BuyRecord = @"auth/account/user/consume/list";//消费记录
NSString * const ChargeRecord = @"auth/account/user/recharge/list";//充值记录
NSString * const MyFuturesList = @"auth/my/futures";//我的期货
NSString * const Redeem = @"auth/product/futures/redeem";//快速赎回
NSString * const SecondMarket = @"auth/add/second/market";//放到二级市场
NSString * const Withdraw = @"auth/user/withdraw";//提现
NSString * const WithdrawTimer = @"auth/user/withdraw/getByMap";//提现到账时间
NSString * const WithdrawAdd = @"auth/user/withdraw/add/account";//添加提现方式
NSString * const WithdrawList = @"auth/account/user/stream/list";//提现记录
NSString * const Recharge = @"auth/order/recharage/create";//充值
NSString * const DrawList = @"auth/user/withdraw/list/account";//提现方式列表
NSString * const DeleteDrawList = @"auth/user/withdraw/delete/account";//删除提现方式
NSString * const UpdateDrawList = @"auth/user/withdraw/update/account";//修改提现方式
NSString * const IWantWine = @"auth/futures/want";//我要酒



@implementation MyCountNetwork

+ (void)getMyCountWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,MyCountModel *mdodel))response
{
    [[GFXNetworkHandle shareHandle]post:MyCount params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            MyCountModel *model = [MyCountModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getIncomeListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:IncomeList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ChargeListModel *model = [ChargeListModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getBuyChargeListWithParame:(NSDictionary *)parames type:(RecoredType)type response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    NSString *url = (type == RecoredTypeBuy)?BuyRecord:ChargeRecord;
    [[GFXNetworkHandle shareHandle]post:url params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ChargeListModel *model = [ChargeListModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getMyFuturesListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:MyFuturesList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                MyFutureModel *model = [MyFutureModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)redeemQuickWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:Redeem params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)putSecondMarketWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:SecondMarket params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)withDrawAddWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:WithdrawAdd params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)withDrawWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSInteger ID))response
{
    [[GFXNetworkHandle shareHandle]post:Withdraw params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"],[json[@"result"] integerValue]);
        }else{
            response(NO,json[@"message"],0);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,0);
    }];
}

+ (void)getWithDrawListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:WithdrawList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ChargeListModel *model = [ChargeListModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)reChargeWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,SingleCreateModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:Recharge params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            SingleCreateModel *model = [SingleCreateModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)drawListsWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:DrawList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                DrawListModel *model = [DrawListModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)updateDrawListsWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:UpdateDrawList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)deleteDrawListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:DeleteDrawList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)wantWineWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:IWantWine params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)withDrawTimeWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSString *duration))response
{
    [[GFXNetworkHandle shareHandle]post:WithdrawTimer params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"],json[@"result"][@"duration"]);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
@end
